//
//  NewLoanCell.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/11/9.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class NewLoanCell: UITableViewCell {
    
    var model : NewLoanModel! {
        didSet{
            updateData()
        }
    }
    
    fileprivate let fontSize = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
    fileprivate let eyeImageView = UIImageView() //眼睛
    fileprivate let titleLabel = UILabel() //标题
    fileprivate let likeLabel = UILabel() //赞

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        eyeImageView.image = UIImage.init(named: "eye")
        self.contentView.addSubview(eyeImageView)
        
        titleLabel.font = fontSize
        self.contentView.addSubview(titleLabel)

        likeLabel.textAlignment = .center
        likeLabel.textColor = UIColor.gray
        likeLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 14))
        self.contentView.addSubview(likeLabel)
        
        likeLabel.snp.makeConstraints { (make) in
            make.centerY.height.equalToSuperview()
            make.right.equalToSuperview().offset(RATIO(maxNum: -10))
            make.width.equalTo(30)
        }
        
        eyeImageView.snp.makeConstraints { (make) in
            make.centerY.equalTo(likeLabel)
        make.right.equalTo(likeLabel.snp.left).offset(RATIO(maxNum: -5))
            make.width.height.equalTo(RATIO_H(maxNum: 20))
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(RATIO(maxNum: 20))
            make.centerY.height.equalToSuperview()
            make.right.equalTo(eyeImageView.snp.left).offset(RATIO(maxNum: -20))
        }
        
    }
    
    //MARK: 更新数据
    fileprivate func updateData() {
        
        titleLabel.text = model.title
        likeLabel.text = model.post_num
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
